package com.across.connect.home;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;

import org.jdom.JDOMException;

import com.across.connect.dao.PlanXmlParser;
import com.across.connect.model.Plan;

public class PlanHome {

	private static PlanHome instance = new PlanHome();

	public static PlanHome getInstance() {
		return instance;
	}

   /*
    * 获取一个用户的计划列表
    * */
	public List<Plan> getPlansByUserID(final int userid) {
		try {
			return PlanXmlParser.getPlanUserByUserid(userid);
		} catch (JDOMException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
	
   /*
    * 获取一个用户的计划列表
    * */
	public Plan getLatestPlantByUserID(final int userid) {
		try {
			return PlanXmlParser.getLatestPlanByUserid(userid);
		} catch (JDOMException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
		
    /*
     * 保存用户的计划
     * */
	public boolean savePlanByUserID(final String personid,
			final String content, final String date) {
		try {
			return PlanXmlParser.addPlanXml(personid, content, date);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (JDOMException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
 
}
